/**
 * 
 */
package com.seascape.swms.system.web;

import org.apache.shiro.subject.Subject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.seascape.swms.framework.model.Result;
import com.seascape.swms.system.shiro.ShiroUtils;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @author Lay
 *
 */
@Api("认证接口")
@RestController
public class LoginController {
	
	@ApiOperation("登录")
	@PostMapping("/login")
    public Result login(@RequestBody Account account) {
		Subject subject = ShiroUtils.login(account.getUsername(), account.getPassword());
        return Result.success(subject.getSession());
    }
	
	@ApiOperation("未认证")
	@GetMapping("/unauth")
    public Result unauth() {
        return Result.unauth();
    }
	

	public static class Account{
		private String username;
		
		private String password;

		/**
		 * @return the username
		 */
		public String getUsername() {
			return username;
		}

		/**
		 * @param username the username to set
		 */
		public void setUsername(String username) {
			this.username = username;
		}

		/**
		 * @return the password
		 */
		public String getPassword() {
			return password;
		}

		/**
		 * @param password the password to set
		 */
		public void setPassword(String password) {
			this.password = password;
		}
		
		
	}
}
